package com.SouthernWall_404.AgeSuitcase.Common.API.Info;

import com.SouthernWall_404.AgeSuitcase.Common.world.item.FileItem;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.ItemStack;
import org.checkerframework.checker.units.qual.C;

public class FileInfo {

    public String date;
    public String code;
    public static String DATE_TAG="date";
    public static String CODE_TAG="code";

    public FileInfo(String date, String code) {
        this.date = date;
        this.code = code;
    }

    public FileInfo(CompoundTag filePack) {
        this.loadFilePack(filePack);
    }
    public FileInfo(ItemStack itemStack)
    {
        CompoundTag modPack= FileItem.getOrCreateModPack(itemStack);

        if(modPack.contains(FileItem.FILE_TAG))
        {
            CompoundTag filePack=modPack.getCompound(FileItem.FILE_TAG);
            this.loadFilePack(filePack);

        }
    }

    public CompoundTag getFilePack()
    {
        CompoundTag filePack=new CompoundTag();
        filePack.putString(DATE_TAG,this.date);
        filePack.putString(CODE_TAG,this.code);

        return filePack;
    }

    public void loadFilePack(CompoundTag filePack)
    {
        if (filePack.contains(DATE_TAG))
        {
            this.date=filePack.getString(DATE_TAG);
        }
        if(filePack.contains(CODE_TAG))
        {
            this.code=filePack.getString(CODE_TAG);
        }
    }
}
